All Questions
183 questions
6votes
3answers
333views
Implementation of arrays that store their size
In this code I implemented arrays that store their own size before the first element. To access it you need to go back exactly sizeof(size_t) bytes back. To free it,...
7votes
3answers
990views
Dynamic Arrays with Count / Capacity in C
I write in C for several projects (e.g. learning / teaching, coding competitions, data processing) and frequently need arrays (e.g. strings) with fast appending / concatenation / reversing. I've ...
3votes
2answers
145views
Todo List app using C
I just learned to deal with pointers and memory allocation stuff. Using that, I built a todo list app, and it works as far as I tested it. I didn't account for many user errors, so any suggestion to ...
2votes
2answers
135views
Generic Dynamic Array Implementation
I wrote a dynamic array implementation in ISO C11 using void pointers. Everything I've implemented works--at least in all my tests--on a 64-bit machine. It has some vague type-checking and resizes ...
6votes
4answers
1kviews
Automate character search in C
THE TASK We are dealing with a string of symbols and need quick responses to queries of the following types: What is the position of the k-th occurrence of symbol X in the string? Reading from ...
2votes
2answers
283views
Optimizing Subarray Removal: Can the Removal Process be Enhanced for Better Efficiency?
The only requirement is that it has to be done by pointers: And it returns the amount of removed numbers because of the way of output that is set in the main. The function, using exclusively pointer ...
6votes
1answer
61views
Chessboard configuartions with no possible capture on the next move
THE TASK: Given an NxM "chess"board and Q,R,B,K where Q is the number of queens, R the number of rooks, B the number of bishops, and K the number of knights find out how many possible ...
4votes
2answers
2kviews
Linked list and array list performance comparison in C
After watching Stroustrup's presentation on performance comparison between vectors and linked lists (https://youtu.be/YQs6IC-vgmo?si=9r5wXqnwkmN29xqn), I've decided it would be a good problem to get a ...
6votes
3answers
647views
3votes
3answers
1kviews
Small code exercise with 3D arrays in C
I wrote a small program that initializes a 3D array in C based on command-line arguments and prints it. I did my best to avoid undefined behavior and memory errors. I wrote comments as if I had an ...
1vote
2answers
266views
Count the number of mismatches between two arrays
This function may compute the amount of unequal elements of two char-arrays of the length n: ...
5votes
1answer
992views
Dynamic array type using void pointers C
I made my own dynamic array type using void pointers. I'd like to know what you think of my implementation. void pointers are nice but I fear they may be inefficient. The compiler cannot tell what ...
8votes
4answers
522views
Array List C implementation
I want to show you my implementation of the array list in C. Is there something I can improve or fix? Header ...
6votes
2answers
195views
First attempt at making a sobel edge detection filter in c
I made a borders filter in C. It works properly, but I think it could be optimized and better designed; the formatting is abysmal. It uses too many lines for the border cases and has too many ...
3votes
1answer
134views
C generic typesafe dynamic array (vector) try 2
The previous generic dynamic array I asked a review for here was written using only the preprocessor and so while the array itself was type-safe, all the manipulating macros where not. In this try I ...